home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / lib / python2.6 / curses / wrapper.pyc (.txt) < prev   
Python Compiled Bytecode  |  2009-11-11  |  1KB  |  42 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''curses.wrapper
  5.  
  6. Contains one function, wrapper(), which runs another function which
  7. should be the rest of your curses-based application.  If the
  8. application raises an exception, wrapper() will restore the terminal
  9. to a sane state so you can read the resulting traceback.
  10.  
  11. '''
  12. import curses
  13.  
  14. def wrapper(func, *args, **kwds):
  15.     """Wrapper function that initializes curses and calls another function,
  16.     restoring normal keyboard/screen behavior on error.
  17.     The callable object 'func' is then passed the main window 'stdscr'
  18.     as its first argument, followed by any other arguments passed to
  19.     wrapper().
  20.     """
  21.     res = None
  22.     
  23.     try:
  24.         stdscr = curses.initscr()
  25.         curses.noecho()
  26.         curses.cbreak()
  27.         stdscr.keypad(1)
  28.         
  29.         try:
  30.             curses.start_color()
  31.         except:
  32.             pass
  33.  
  34.         return func(stdscr, *args, **kwds)
  35.     finally:
  36.         stdscr.keypad(0)
  37.         curses.echo()
  38.         curses.nocbreak()
  39.         curses.endwin()
  40.  
  41.  
  42.